<%@include file="/_checkSession.jsp"%>

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width">

        <link rel="stylesheet" href="css/bootstrap.min.css">
        <style>
            body {
                padding-top: 60px;
                padding-bottom: 40px;
            }
        </style>
        <link rel="stylesheet" href="css/bootstrap-responsive.min.css">
        <link rel="stylesheet" href="css/main.css">
        <link href="${pageContext.request.contextPath}/css/epubopzczm55fn4cqrgb14a1c.css?dataUri=true" type="text/css" rel="stylesheet">
		<link href="${pageContext.request.contextPath}/css/cqjtvthoh24nrgx54w13elnqm.css?dataUri=true" type="text/css" rel="stylesheet">

        <script src="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
                <script type="text/javascript">
    	function validate()
    	{
			var msg = "Sorry, incorrect input.\n\n"; 
    		var itemname = document.getElementsByName("itemname")[0];
    		var itemdetail = document.getElementsByName("itemdetail")[0];
    		
    		var co = document.getElementsByName("co")[0];
    		var bo = document.getElementsByName("bo")[0];
    		
    		var price = /^(\d*\.\d{0,2}|\d+).*$/;
    		
    		if(itemname.value.length == 0)
    		{
					alert(msg + "Item Name can't be blank!\n");
					return false;
    		}
    		
    		
    		if(itemdetail.value.length < 3)
    		{
    			
    			alert(msg + "length of Item Detail  must be greater then 3 !\n");
    			return false;
    		}

    		if(co.value.length == 0){
					alert(msg + "Starting Price can't be blank!\n");
					return false;
    		}
    		
    		
    		if(!co.value.match(price)){ 
  				alert(msg + "Starting Price wrong!\n");
  				co.value = '';
                co.focus();
				return false;
  			}
    		
     		if(bo.value.length == 0) {}
     		else{
	    		
	    		if(!bo.value.match(price)){ 
  				alert(msg + "Buyout Price wrong!\n");
  				bo.value = '';
                bo.focus();
				return false;
  				}}
  			
  			if(bo.value.length == 0) {}
     		else{	
  			if(co.value >= bo.value){
	    		alert(msg + "The Strating Price must be less than BuyOut Price !\n");
	    		return false;
	    	}}
 
    		return true;
    	}
    
    
    </script>
    </head>
    <body>
        <div class="container">

            <!-- Main hero unit for a primary marketing message or call to action -->
            <div class="hero-unit">
                <h1>Sell</h1>
                
                <font color=ea0000 size="2"> *</font> &nbsp; <font color=5b5b5b size="2"> necessary area</font> 
                <form  onsubmit="return validate()" class="navbar-form" action="RequestProcess" method="post"  enctype="multipart/form-data">
                	
                	<table>
                		<tr>
                			<td><font color=ea0000 size="2"> *</font></td>
                			<td> Item Name: </td>
                			<td><input class="span3" type="text" name="itemname"> </td>
                		</tr>
                		<tr>
                			<td><font color=ea0000 size="2"> *</font></td>
                			<td> Category: </td>
                			<td> <select name="category">
                			 		<jsp:include page="getCategory.jsp"></jsp:include> 
                			    </select> 
                			 </td>
                		</tr>
                		<tr>
                			<td><font color=ea0000 size="2"> *</font></td>
                			<td> Item Detail: </td>
                			<td> <textarea class="span3" name="itemdetail" rows="4" cols="50"></textarea> </td>
                			<td> <font color=7b7b7b size="2"> &nbsp;use at least 3 characters</font> </td>
                		</tr>
                		<tr>
                			<td><font color=#eee size="2"> *</font></td>
                			<td> Image: </td>
                			<td> <input type="file" name="image"> </td>
                		</tr>
                		<tr>
                			<td><font color=ea0000 size="2"> *</font></td>
                			<td> Selling duration: </td>
                			<td> <select name="duration">
                				<option value="10">10 days</option>
                				<option value="20">20 days</option>
                				<option value="30">1 month</option>
                			     </select> 
                			 </td>
                		</tr>
                		<tr>
                			<td><font color=ea0000 size="2"> *</font></td>
                			<td> Starting Price: </td>
                			<td>&nbsp; $ <input type="text"  name="co"> </td>
                		</tr>
                		<tr>
                			<td><font color=#eee size="2"> *</font></td>
                			<td> BuyOut Price: </td>
                			<td>&nbsp; $  <input type="text" name="bo"> </td>
                		</tr>
                	
                	</table>
                	
                     <br> 
                    
                    <input type="hidden" name="type" value="sell">
                    <input type="hidden" name="uid" value=<%= session.getAttribute("uid") %>>
                    <input type="hidden" name="sid" value=<%= session.getAttribute("sid") %>>
                    
                    <br>
                    <button type="submit" class="btn btn-primary">Sell</button>
                </form>                
                
            </div>

            <!-- Example row of columns -->

            <hr>

        </div> <!-- /container -->

        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
        <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.9.1.min.js"><\/script>')</script>

        <script src="js/vendor/bootstrap.min.js"></script>

        <script src="js/main.js"></script>

        <script>
            var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
            (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
            g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
            s.parentNode.insertBefore(g,s)}(document,'script'));
        </script>
    </body>
</html>
